package com.dalin.platform.autocode.action;

import java.util.List;

import com.dalin.framework.action.StrutsTwoAction;
import com.dalin.platform.autocode.condition.GlbDicTypeRepositoryCondition;
import com.dalin.platform.autocode.service.AutocodeService;
import com.dalin.platform.autocode.vo.GlbDicTypeRepositoryVo;
import com.dalin.platform.glb.model.GlbDicTypeRepositoryEntity;
/*****************************************************************************
 * @content: 类信息                                                   *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-07-12                                                     *
 * @modDate: 2010-07-12                                                     *
 * @version: 1.00                                                           *
 ****************************************************************************/
public class GlbDicTypeReposAddModAction extends StrutsTwoAction{
	private AutocodeService autocodeService; // 
    private GlbDicTypeRepositoryVo vo; // 

    public String execute()throws Exception {
    	super.printInfo("", "===== this action begin");
        // 类型代码检查 begin
		GlbDicTypeRepositoryCondition cond = new GlbDicTypeRepositoryCondition();
		cond.setTypeCode(vo.getTypeCode());
	    List<GlbDicTypeRepositoryEntity> dataList = autocodeService
	    		.queryListByCond(cond.prepareParams());
	    if (dataList.size() > 0 && !dataList.get(0).getTypeId()
	    		 .equals(vo.getTypeId())) {
	    	setResContent(false, "类型代码重复,请您仔细检查");
	        return null;
	    }
        // 类型代码检查 over
        if (vo.getTypeId() == null) {
        	autocodeService.addGlbDicTypeRepository(vo);
        } else {
        	autocodeService.modifyGlbDicTypeRepository(vo);
        }
        setResContent(true, "");
        super.printInfo("", "===== this action end");
        return null;
    }
    
    
    

    public AutocodeService getAutocodeService() {
		return autocodeService;
	}
	public void setAutocodeService(AutocodeService autocodeService) {
		this.autocodeService = autocodeService;
	}

	public GlbDicTypeRepositoryVo getVo() {
		return vo;
	}

	public void setVo(GlbDicTypeRepositoryVo vo) {
		this.vo = vo;
	}
}
